/* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
(function(a){function b(a){return a&&a.Object===Object?a:null}var c={"function":!0,object:!0},d=c[typeof exports]&&exports&&!exports.nodeType?exports:null,e=c[typeof module]&&module&&!module.nodeType?module:null,f=b(d&&e&&"object"==typeof global&&global),g=b(c[typeof self]&&self),h=b(c[typeof window]&&window),i=(e&&e.exports===d?d:null,b(c[typeof this]&&this)),j=f||h!==(i&&i.window)&&h||g||i||Function("return this")();"function"==typeof define&&define.amd?define(["./rx"],function(b,c){return a(j,c,b)}):"object"==typeof module&&module&&module.exports===d?module.exports=a(j,module.exports,require("./rx")):j.Rx=a(j,{},j.Rx)}).call(this,function(a,b,c,d){function e(a){return function(){try{return a.apply(this,arguments)}catch(b){return D.e=b,D}}}function f(a){return a.toArray()}function g(a,b){return a.groupJoin(this,b,t,function(a,b){return b})}function h(a){var b=this;return new v(function(c){var d=new r,e=new m,f=new o(e);return c.onNext(w(d,f)),e.add(b.subscribe(function(a){d.onNext(a)},function(a){d.onError(a),c.onError(a)},function(){d.onCompleted(),c.onCompleted()})),A(a)&&(a=C(a)),e.add(a.subscribe(function(a){d.onCompleted(),d=new r,c.onNext(w(d,f))},function(a){d.onError(a),c.onError(a)},function(){d.onCompleted(),c.onCompleted()})),f},b)}function i(a){var b=this;return new v(function(c){function d(){var b;try{b=a()}catch(f){return void c.onError(f)}A(b)&&(b=C(b));var i=new p;e.setDisposable(i),i.setDisposable(b.take(1).subscribe(z,function(a){h.onError(a),c.onError(a)},function(){h.onCompleted(),h=new r,c.onNext(w(h,g)),d()}))}var e=new q,f=new m(e),g=new o(f),h=new r;return c.onNext(w(h,g)),f.add(b.subscribe(function(a){h.onNext(a)},function(a){h.onError(a),c.onError(a)},function(){h.onCompleted(),c.onCompleted()})),d(),g},b)}var j=c.Observable,k=c.ObservableBase,l=c.internals.AbstractObserver,m=c.CompositeDisposable,n=c.BinaryDisposable,o=c.RefCountDisposable,p=c.SingleAssignmentDisposable,q=c.SerialDisposable,r=c.Subject,s=j.prototype,t=j.empty,u=j.never,v=c.AnonymousObservable,w=c.internals.addRef,x=c.internals.inherits,y=c.internals.bindCallback,z=c.helpers.noop,A=c.helpers.isPromise,B=c.helpers.isFunction,C=j.fromPromise,D={e:{}},E=c.internals.tryCatch=function(a){if(!B(a))throw new TypeError("fn must be a function");return e(a)},F=a.Map||function(){function a(){this.size=0,this._values=[],this._keys=[]}return a.prototype["delete"]=function(a){var b=this._keys.indexOf(a);return-1===b?!1:(this._values.splice(b,1),this._keys.splice(b,1),this.size--,!0)},a.prototype.get=function(a){var b=this._keys.indexOf(a);return-1===b?d:this._values[b]},a.prototype.set=function(a,b){var c=this._keys.indexOf(a);return-1===c?(this._keys.push(a),this._values.push(b),this.size++):this._values[c]=b,this},a.prototype.forEach=function(a,b){for(var c=0;c<this.size;c++)a.call(b,this._values[c],this._keys[c])},a}();s.join=function(a,b,c,d){var e=this;return new v(function(f){var g=new m,h=!1,i=!1,j=0,k=0,l=new F,n=new F,o=function(a){f.onError(a)};return g.add(e.subscribe(function(a){var c=j++,e=new p;l.set(c,a),g.add(e);var i=E(b)(a);return i===D?f.onError(i.e):(e.setDisposable(i.take(1).subscribe(z,o,function(){l["delete"](c)&&0===l.size&&h&&f.onCompleted(),g.remove(e)})),void n.forEach(function(b){var c=E(d)(a,b);return c===D?f.onError(c.e):void f.onNext(c)}))},o,function(){h=!0,(i||0===l.size)&&f.onCompleted()})),g.add(a.subscribe(function(a){var b=k++,e=new p;n.set(b,a),g.add(e);var h=E(c)(a);return h===D?f.onError(h.e):(e.setDisposable(h.take(1).subscribe(z,o,function(){n["delete"](b)&&0===n.size&&i&&f.onCompleted(),g.remove(e)})),void l.forEach(function(b){var c=E(d)(b,a);return c===D?f.onError(c.e):void f.onNext(c)}))},o,function(){i=!0,(h||0===n.size)&&f.onCompleted()})),g},e)},s.groupJoin=function(a,b,c,d){var e=this;return new v(function(f){function g(a){}var h=new m,i=new o(h),j=new F,k=new F,l=0,n=0,g=function(a){return function(b){b.onError(a)}};return h.add(e.subscribe(function(a){var c=new r,e=l++;j.set(e,c);var m=E(d)(a,w(c,i));if(m===D)return j.forEach(g(m.e)),f.onError(m.e);f.onNext(m),k.forEach(function(a){c.onNext(a)});var n=new p;h.add(n);var o=E(b)(a);return o===D?(j.forEach(g(o.e)),f.onError(o.e)):void n.setDisposable(o.take(1).subscribe(z,function(a){j.forEach(g(a)),f.onError(a)},function(){j["delete"](e)&&c.onCompleted(),h.remove(n)}))},function(a){j.forEach(g(a)),f.onError(a)},function(){f.onCompleted()})),h.add(a.subscribe(function(a){var b=n++;k.set(b,a);var d=new p;h.add(d);var e=E(c)(a);return e===D?(j.forEach(g(e.e)),f.onError(e.e)):(d.setDisposable(e.take(1).subscribe(z,function(a){j.forEach(g(a)),f.onError(a)},function(){k["delete"](b),h.remove(d)})),void j.forEach(function(b){b.onNext(a)}))},function(a){j.forEach(g(a)),f.onError(a)})),i},e)},s.buffer=function(){return this.window.apply(this,arguments).flatMap(f)},s.window=function(a,b){return 1===arguments.length&&"function"!=typeof arguments[0]?h.call(this,a):"function"==typeof a?i.call(this,a):g.call(this,a,b)};var G=function(a){function b(b){this.source=b,a.call(this)}return x(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new H(a))},b}(k),H=function(a){function b(b){this._o=b,this._p=null,this._hp=!1,a.call(this)}return x(b,a),b.prototype.next=function(a){this._hp?this._o.onNext([this._p,a]):this._hp=!0,this._p=a},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){this._o.onCompleted()},b}(l);s.pairwise=function(){return new G(this)},s.partition=function(a,b){var c=y(a,b,3);return[this.filter(a,b),this.filter(function(a,b,d){return!c(a,b,d)})]},s.groupBy=function(a,b){return this.groupByUntil(a,b,u)},s.groupByUntil=function(a,b,c){var e=this;return new v(function(f){var g=new F,h=new m,i=new o(h),j=function(a){return function(b){b.onError(a)}};return h.add(e.subscribe(function(e){var k=E(a)(e);if(k===D)return g.forEach(j(k.e)),f.onError(k.e);var l=!1,m=g.get(k);if(m===d&&(m=new r,g.set(k,m),l=!0),l){var n=new J(k,m,i),o=new J(k,m),q=E(c)(o);if(q===D)return g.forEach(j(q.e)),f.onError(q.e);f.onNext(n);var s=new p;h.add(s),s.setDisposable(q.take(1).subscribe(z,function(a){g.forEach(j(a)),f.onError(a)},function(){g["delete"](k)&&m.onCompleted(),h.remove(s)}))}var t=e;return B(b)&&(t=E(b)(e),t===D)?(g.forEach(j(t.e)),f.onError(t.e)):void m.onNext(t)},function(a){g.forEach(j(a)),f.onError(a)},function(){g.forEach(function(a){a.onCompleted()}),f.onCompleted()})),i},e)};var I=function(a){function b(b,c){this._m=b,this._u=c,a.call(this)}return x(b,a),b.prototype.subscribeCore=function(a){return new n(this._m.getDisposable(),this._u.subscribe(a))},b}(k),J=function(a){function b(b,c,d){a.call(this),this.key=b,this.underlyingObservable=d?new I(d,c):c}return x(b,a),b.prototype._subscribe=function(a){return this.underlyingObservable.subscribe(a)},b}(j);return c});
//# sourceMappingURL=rx.coincidence.map